//
//  CSL_Search_MVCell.m
//  HZ_Beautiful_Music
//
//  Created by dllo on 16/4/3.
//  Copyright © 2016年 ui. All rights reserved.
//

#import "CSL_Search_MVCell.h"
#import <UIImageView+WebCache.h>
#import "WDGDatabaseTool.h"
#import "Search_MV_Data_mvListModel.h"
#import "CSL_CollecModel.h"

@interface CSL_Search_MVCell ()

@property (nonatomic, strong) WDGDatabaseTool *collectionHandler;
@property (nonatomic, strong) NSMutableArray *mutableArray;
@property (nonatomic, strong) CSL_CollecModel *collecModel;

@end

@implementation CSL_Search_MVCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
#pragma mark - 创建收藏数据库
        [UIFont systemFontSize];
        
        
        self.mvImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
//        _mvImageView.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_mvImageView];
        
        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
//        _titleLabel.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_titleLabel];
        
        self.nameLabel = [[UILabel alloc] initWithFrame:CGRectZero];
//        _nameLabel.backgroundColor = [UIColor redColor];
        _nameLabel.textColor = [UIColor colorWithWhite:0.441 alpha:1.000];
        _nameLabel.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:_nameLabel];
    
        self.playerImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
//        _playerImageView.backgroundColor = [UIColor redColor];
        _playerImageView.image = [[UIImage imageNamed:@"leguanMV64"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        [self.contentView addSubview:_playerImageView];
        
        self.playerLabel = [[UILabel alloc] initWithFrame:CGRectZero];
//        _playerLabel.backgroundColor = [UIColor redColor];
        _playerLabel.textColor = [UIColor grayColor];
        _playerLabel.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:_playerLabel];
        
        self.commentsImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
//        _commentsImageView.backgroundColor = [UIColor redColor];
        _commentsImageView.image = [[UIImage imageNamed:@"pinglun64"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        [self.contentView addSubview:_commentsImageView];
        
        self.commentsLabel = [[UILabel alloc] initWithFrame:CGRectZero];
//        _commentsLabel.backgroundColor = [UIColor redColor];
        _commentsLabel.textColor = [UIColor grayColor];
        _commentsLabel.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:_commentsLabel];
        
        self.footView = [[UIView alloc] initWithFrame:CGRectZero];
        _footView.backgroundColor = [UIColor colorWithWhite:0.896 alpha:1.000];
        [self.contentView addSubview:_footView];
    }
    return self;
}

-(void)layoutSubviews {
    [super layoutSubviews];
    _mvImageView.frame = CGRectMake(self.bounds.size.width/20, self.bounds.size.height/15, self.bounds.size.width/2.5, self.bounds.size.height/1.15);
    _titleLabel.frame = CGRectMake(self.bounds.size.width/2, self.bounds.size.height/5, self.bounds.size.width/3, self.bounds.size.height/4.5);
    _nameLabel.frame = CGRectMake(self.bounds.size.width/2, self.bounds.size.height/2.2, self.bounds.size.width/3, self.bounds.size.height/6);
    _playerImageView.frame = CGRectMake(self.bounds.size.width/2, self.bounds.size.height/1.4, self.bounds.size.width/15, self.bounds.size.height/6);
    _playerLabel.frame = CGRectMake(self.bounds.size.width/1.78, self.bounds.size.height/1.4, self.bounds.size.width/8, self.bounds.size.height/7);
    _commentsImageView.frame = CGRectMake(self.bounds.size.width/1.4, self.bounds.size.height/1.4, self.bounds.size.width/20, self.bounds.size.height/8);
    _commentsLabel.frame = CGRectMake(self.bounds.size.width/1.29, self.bounds.size.height/1.4, self.bounds.size.width/8, self.bounds.size.height/7);
    _footView.frame = CGRectMake(0, self.bounds.size.height - 1, self.bounds.size.width, 1);
}

-(void)setMv_dataModel:(Search_MV_dataModel *)mv_dataModel {
    
    _mv_dataModel = mv_dataModel;
    [_mvImageView sd_setImageWithURL:[NSURL URLWithString:_mv_dataModel.picUrl] placeholderImage:[[UIImage imageNamed:@"Music"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    _titleLabel.text = mv_dataModel.videoName;
    _nameLabel.text = mv_dataModel.singerName;
    NSNumberFormatter *number = [[NSNumberFormatter alloc] init];
    _playerLabel.text = [number stringFromNumber:mv_dataModel.pickCount];
    NSNumberFormatter *bullnumber = [[NSNumberFormatter alloc] init];
    _commentsLabel.text = [bullnumber stringFromNumber:mv_dataModel.bulletCount];
}





@end
